
Last chance! 50% off unlimited learning
Sale ends in
Calculates the ratio of Bessel K functions of different orders, but the same value of the argument.
besselRatio(x, nu, orderDiff, useExpScaled = 700)
Numeric,
Numeric. The order of the Bessel function in the denominator.
Numeric. The order of the numerator Bessel function minus the order of the denominator Bessel function.
Numeric,
The ratio
Uses the function besselK
to calculate the ratio of two
modified Bessel function of the third kind whose orders are
different. The calculation of Bessel functions will underflow if the
value of besselK
. The ratio is actually unaffected by exponential
scaling since the scaling cancels across numerator and denominator.
The Bessel function ratio is useful in calculating moments of the generalized inverse Gaussian distribution, and hence also for the moments of the hyperbolic and generalized hyperbolic distributions.
# NOT RUN {
nus <- c(0:5, 10, 20)
x <- seq(1, 4, length.out = 11)
k <- 3
raw <- matrix(nrow = length(nus), ncol = length(x))
scaled <- matrix(nrow = length(nus), ncol = length(x))
compare <- matrix(nrow = length(nus), ncol = length(x))
for (i in 1:length(nus)){
for (j in 1:length(x)) {
raw[i,j] <- besselRatio(x[j], nus[i],
orderDiff = k)
scaled[i,j] <- besselRatio(x[j], nus[i],
orderDiff = k, useExpScaled = 1)
compare[i,j] <- raw[i,j]/scaled[i,j]
}
}
raw
scaled
compare
# }
Run the code above in your browser using DataLab